Executing Workflows

You can execute a workflow in these ways:

  • On a page event; see Page Layout Properties.
  • According to a workflow schedule; see Workflow Schedules.
  • When data is inserted, deleted or updated in a data object. See Data Object Triggers.
  • When a page control is clicked or changed—depending on the particular control. See details of particular controls in the Controls Reference topics: Introduction to Controls. A button control is commonly used and is explained below.
  • Using JavaScript as explained below.

Executing a workflow with a control or page layout

A button control has been used for this section; other controls are similar.

When a workflow is executed by a control or the page layout, any input parameters it uses must be supplied by the values of controls, and any output the workflow returns must be directed to a control.

In the workflow, the input and output parameters (if any) are configured in the workflow like this.

Input parameters

Output parameters

Warning | When configuring input and output parameters in a workflow, use alphanumeric characters only.

Whenever you configure the Behaviour properties of a control or the page layout to execute a workflow, the workflow input and output Name parameters are read and presented for configuration in the web page control or layout.

You specify in the configuration which controls will supply the input parameters to the workflow and which will display any output.

This example of a button control provides two input parameters to a workflow. The parameter values are set by the values of two text boxes, and the workflow output is directed to a third text box:

Note | "Workflow: Object reference not set to an instance of an object". If this message is displayed when you attempt to execute a workflow, check that it is published.

Executing a workflow with JavaScript

You execute a workflow in JavaScript using the FSI JavaScript API method, fsi.workflow(); see FSI API: Workflows.

The fsi.workflow() method supplies any input parameters the workflow uses and handles any output.

The page JavaScript code below executes the workflow example described above in Executing a workflow with a control or page layout.

The input parameters are submitted to the workflow as an object.

function add2Numbers() {
  var inputParam1=fsi.getById('text-in1');
  var inputParam2=fsi.getById('text-in2');
  var inputs = {"WfInput1":inputParam1,"WfInput2":inputParam2};
  var outputs = {};
  fsi.workflow('Add2NumbersNew', inputs, null, null,
    function (myResponseData) {
     var total = myResponseData.MyResult;
     fsi.setById('text-out', total);
    },
    function (errorData) { debugger; });
}

See Elementary Workflow in the Tutorials section to see a detailed example,